<?php

namespace app\api\controller;

use app\common\lib\Param;
use app\common\lib\Show;
use app\common\lib\Str;
use app\Request;
use think\facade\Cache;
use think\response\Json;

class Leadership extends ApiBase
{
    public function index(): Json
    {
        $type = input("type", 0, "intval");

        $leadershipBis = new \app\common\business\Leadership();

        $map = [];
        $type != 0 && $map[] = ['type','=',$type];

        try {
            $list = $leadershipBis->getListByWhereWithOrder($map,0,0,'sort desc,id desc','id,name,face,position');
            $count = $leadershipBis->getCountByWhere($map);
        } catch (\Exception $e) {
            return Show::error([], $e->getMessage(), $e->getCode());
        }

        $result = [
            'count'=>$count,
            'list'=>$list
        ];
        return Show::success($result);
    }

    /*public function detail(): Json
    {
        $id = input("id", 0, "intval");

        $noticeBis = new \app\common\business\Leadership();

        try {
            $info = $noticeBis->getNormalById($id);
        } catch (\Exception $e) {
            return Show::error([], $e->getMessage(), $e->getCode());
        }

        !empty($info) && $info = $noticeBis->resetInfo([$info]);
        return Show::success($info);
    }*/
}
